package com.example.mobile2121606109ycg0429homework;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private RecyclerView tvMainCarItem;
    private List<Car> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();

        tvMainCarItem.setLayoutManager(new LinearLayoutManager(this));
        CarRVAdapter adapter = new CarRVAdapter(list);
        tvMainCarItem.setAdapter(adapter);

    }

    private void initData() {
        list = new ArrayList<>();
        list.add(new Car(R.drawable.line01_01,"轿车车型生产环节1","轿车汽车放置底盘"));
        list.add(new Car(R.drawable.line01_02,"轿车车型生产环节2","轿车汽车左前悬挂"));
        list.add(new Car(R.drawable.line01_03,"轿车车型生产环节3","轿车汽车右前悬挂"));
        list.add(new Car(R.drawable.line01_04,"轿车车型生产环节4","轿车汽车左后悬挂"));
        list.add(new Car(R.drawable.line01_05,"轿车车型生产环节5","轿车汽车右后悬挂"));
        list.add(new Car(R.drawable.line01_06,"轿车车型生产环节6","轿车汽车固定车架"));
        list.add(new Car(R.drawable.line01_07,"轿车车型生产环节7","轿车汽车发动机"));
        list.add(new Car(R.drawable.line01_08,"轿车车型生产环节8","轿车汽车椅子"));
        list.add(new Car(R.drawable.line01_09,"轿车车型生产环节9","轿车汽车方向盘"));
        list.add(new Car(R.drawable.line01_10,"轿车车型生产环节10","轿车汽车左前车门"));
        list.add(new Car(R.drawable.line01_11,"轿车车型生产环节11","轿车汽车右前车门"));
    }

    private void initView() {
        tvMainCarItem = (RecyclerView) findViewById(R.id.tvMainCarItem);
    }
}